//
//  YuViewController.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/13.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "YuViewController.h"//逾期未跟进的客户

#import "YuCustomCell.h"

#import "VisitingDetailViewController.h"
#import "CallDetailsViewController.h"
#import "NewGenJinVC.h"
@interface YuViewController ()<UITableViewDelegate,UITableViewDataSource>

{
     NSMutableArray *_yuArr;
    NSString *keStr;
}
@property(nonatomic,strong)UITableView *tabView;
@end

@implementation YuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"逾期未跟进";
    
    _yuArr = [NSMutableArray arrayWithCapacity:0];
    _yuArr = [_yuDic objectForKey:@"data"];
    _tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, B_WIDTH, B_HEIGHT) style:UITableViewStylePlain];
    _tabView.delegate = self;
    _tabView.dataSource = self;
    _tabView.rowHeight = 50;
    _tabView.backgroundColor = BgColor;
    _tabView.separatorStyle = UITableViewCellSelectionStyleNone;//去掉cell的分割线
    [self.view addSubview:_tabView];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_yuStr intValue];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"Cell";
    YuCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil)
    {
        cell = [[YuCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    if ([cell isKindOfClass:[YuCustomCell class]])
    {
        if (_yuArr.count != 0)
        {
            NSDictionary *dict = [_yuArr objectAtIndex:indexPath.row];
            
            [(YuCustomCell *)cell setUpYuQiCellWithName:dict[@"name"] withSex:dict[@"sex"] withVisit:dict[@"yuqi_name"] withLast:dict[@"time"] withYuDay:dict[@"yuqi"] withPhone:dict[@"phone"]];
            
        }
    }
      [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//取消点击
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    keStr = [[_yuArr objectAtIndex:indexPath.row] objectForKey:@"yuqi_name"];
//    if ([keStr isEqualToString:@"来电客户"])
//    {
//        CallDetailsViewController *callDetailVC = [[CallDetailsViewController alloc] init];
//        callDetailVC.callID = [[_yuArr objectAtIndex:indexPath.row] objectForKey:@"id"];
//        callDetailVC.isFirst= YES;
//        [self.navigationController pushViewController:callDetailVC animated:NO];
//        
//    }
//    else
//    {
//        NewGenJinVC *visitVC = [[NewGenJinVC alloc] init];
//        visitVC.genID =  [[_yuArr objectAtIndex:indexPath.row] objectForKey:@"id"];
//         [self.navigationController pushViewController:visitVC animated:NO];
////        VisitingDetailViewController *visitDetailVC = [[VisitingDetailViewController alloc] init];
////        visitDetailVC.visitID = [[_yuArr objectAtIndex:indexPath.row] objectForKey:@"id"];
////        visitDetailVC.isFirst = YES;
////        [self.navigationController pushViewController:visitDetailVC animated:NO];
//    }

    
    
    
    NewGenJinVC *visitVC = [[NewGenJinVC alloc] init];
    visitVC.genID =  [[_yuArr objectAtIndex:indexPath.row] objectForKey:@"id"];
    NSLog(@"-------这个是多少-----%@",visitVC.genID);
    visitVC.keType = keStr;
    [self.navigationController pushViewController:visitVC animated:NO];
    
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
